<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="hexinyang">			
		<title>卡操作明细</title>
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="../script/print.js"></script>
		<script language="javascript" type="text/javascript">
			var qt = {};				//数据表格对象
			//页面加载方法

			function load(){
				Eui.showNavigation()
				setPages(["listview","detview"]);
				var list = [];
				var m_type = Common.getItems("log_list");
				for (var i = 0;i<m_type.length;i++){
					var d = m_type[i];
					if(d.code>110000&&d.code<121000)
						list.push(d);
				}
				Common.initDict(searchForm.type,list,"全 部");		//初始化字典
				var org = Common.cOrg()
				searchForm.currentOrg.value = org.id;						
				searchForm.currentOrgLevel.value = org.orgLevel;
				createTable();										//创建表格对象
			}
			//创建表格对象
			function createTable(){
				var columns = [];
				columns[20] = {
					title : "操作",
					render : function(v,r){
						return "<a href=# onclick='onView("+r[0]+","+r[9]+")'>明细</a>"
					}
				}
				qt = new QueryTable("card_oper_log","searchForm","datalist",columns);
			}
			
			/**查询部分**/
			function sel(){
				var time = searchForm.recordTime.value;         //操作日期
				if(time){												 //如果存在操作日期将日期限制在当天
					var arrtime =time.split("-");
					var todaytime = new Date(arrtime[0],arrtime[1]-1,arrtime[2]);
					todaytime.setDate(todaytime.getDate()+1);
					searchForm.todaytime.value = todaytime.format();;
				}else{
					searchForm.todaytime.value = "";
				}
				qt.showTable();										 //刷新表格
			}
			//选择机构方法
			function searchSelOrg(){
				SystemMgnt.selOrg(function(sorg) {
						searchForm.orgName.value = sorg.name;
					},{funcType : Constants.SELORG_ALL});
			}
			
			function onView(logId,logType){
				DWR.call("cardMgntService.findCardLog",logId,function(res){
					if (CardMgnt.billTypeMap[logType]){
						$("printBtn").style.display = "";
					}else{
						$("printBtn").style.display = "none";
					}
					var log = res.log;
					log.recordTimeText = log.recordTime?log.recordTime.format("yyyy-MM-dd hh:mm:ss"):''
					log.cardUserUniqueId = res.cardUser?res.cardUser.uniqueId:''
					if (res.operator){
						log.operatorUniqueId = res.operator.uniqueId
						log.operatorName = res.operator.name
					}
					if (res.org){
						log.orgUniqueId = res.org.uniqueId
						log.orgName = res.org.name
					}
					if (res.orgUser){
						log.orgUserUniqueId = res.orgUser.uniqueId
					}
					if (res.companyCustomer){
						log.orgUserName = res.companyCustomer.name
					}
					log.foregiftAmount = Format.fenToYuan(log.foregift)
					log.feeAmount = Format.fenToYuan(log.fee)
					log.typeText = Common.getText("log_list",log.type)
					Common.showDetail("detview",log);
					if(res.batchList && res.batchList.length > 0){
						var items = []
						items.push(["cardUserUniqueId","客户编号"])
						items.push(["asn","卡号"])
						var list = []
						for (var i = 0;i<res.batchList.length;i++){
							var c = res.batchList[i]
							list.push(c)
						}
						$("batchList").innerHTML = DetailPage.Misc.List2Table(list,items)
						
						$("subLogDiv").style.display = "";
					}else{
						$("subLogDiv").style.display = "none";
					}
					var billType = null;
					var c = res.card;
					var cu = res.cardUser;
					var ct = res.cardType;
					if (c && c.baseCardType == BaseCardType.PSAM)
						billType = "psam"
					else if (c && c.baseCardType == BaseCardType.OPERATOR)
						billType = "operator"
					else if ((c && c.baseCardType == BaseCardType.COMPANY) || (cu && cu.type == CardUserType.DRIVER))
						billType = "driver"
					else if ((c && c.baseCardType == BaseCardType.PERSONAL) || (cu && cu.type == CardUserType.NAME)){
						if (ct && ct.anonymous)
							billType = "anonymous"
						else
							billType = "personal"
					}
					CardMgnt.drawPrintView("billview",logType,logId,billType)
					switchPage("detview");
					
				},{blockScreen:true})
			}
			function onPrint(){
				WebPrint.print('billview')
			}
		</script>
	</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="listview" >
		<!--查询表单-->
		<form id="searchForm" name="searchForm">
			<div class="searchForm">
				<input type="hidden" name="currentOrgLevel">
				<input type="hidden" name="currentOrg">
				<table width="100%" cellspacing="0" cellpadding="4" border="0" class="label5">
					<tr>
						<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" onBlur="checkV(this,'asn')"></td>
						<td><label>操作类型</label> <select name="type" onBlur="checkV(this,'number')"><option></option></select></td>
						<td><label>操作日期</label> <input type="text" name="recordTime" onBlur="checkV(this,'_pastDate')"><a href="javascript:void(0)" onclick="showDatePicker(searchForm.recordTime);" class="date" title="选择日期">&nbsp;&nbsp;</a></td>
						<td><input type="hidden" name="todaytime"></td>								
					</tr>
					<tr>
						<td><label>操作地点</label> <input type="text" name="orgName" class="readonly" maxlength="20"> <a class="orga" title="选择所属机构" href="javascript:void(0)" onclick="searchSelOrg();">&nbsp;&nbsp;</a></td>
						<td><label>操作员编号</label> <input type="text" name="uniqueId"></td>						
						<td><button type="button" onClick="sel()">查 询</button></td>
					</tr>	
				</table>
			</div>
		</form>			
		<div id="datalist"></div>
	</div>
	<div id="detview" style="display:none;">
		<div class="form">
		<div class="formTitle">卡操作明细</div>
			<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable label6">
				<tr>
					<td><label>业务流水号</label> <span id="id"></span></td>
					<td><label>业务时间</label> <span id="recordTimeText"></span></td>
				</tr>
				<tr>
					<td><label>客户编号</label> <span id="cardUserUniqueId"></span></td>
					<td><label>卡 号</label> <span id="asn"></span></td>
				</tr>
				<tr>
					<td><label>单位客户编号</label> <span id="orgUserUniqueId"></span></td>
					<td><label>单位客户名称</label> <span id="orgUserName"></span></td>
				</tr>
				<tr>
					<td><label>操作员编号</label> <span id="operatorUniqueId"></span></td>
					<td><label>操作员名称</label> <span id="operatorName"></span></td>
				</tr>
				<tr>
					<td><label>操作地点编号</label> <span id="orgUniqueId"></span></td>
					<td><label>操作地点名称</label> <span id="orgName"></span></td>
				</tr>
				<tr>
					<td><label>押 金</label> <span id="foregiftAmount"></span> &nbsp;元</td>
					<td><label>手续费</label> <span id="feeAmount"></span> &nbsp;元</td>
				</tr>
				<tr>
					<td><label>操作类型</label> <span id="typeText"></span></td>
					<td><label>描 述</label> <span id="description"></span></td>
				</tr>
			</table>
		</div>
		<div class="form" id="subLogDiv" style="display:none;">
			<div class="formTitle">关联日志</div>
			<div id="batchList"></div>
		</div>
		<p>
			<button id="printBtn" onclick="onPrint()">打 印</button>
			<button onclick="switchPage('listview')">返 回</button>
		</p>
	</div>
	<div id="billview" style="display:none;"></div>
</body>
</html>